<div class="layui-card-header layui-card">
    <span class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">首页</a>
        <a><cite>订单</cite></a>
        <a><cite>分账记录</cite></a>
    </span>
</div>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">分账记录列表</li>
            </ul>

            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">

                    <div class="layui-row">
                        <div class="layui-form" style="float:right; margin-bottom: 10px;">
                            <div class="layui-form-item" style="margin:0;">

                                <div class="layui-input-inline">
                                    <input type="text"id="payOrderId" placeholder="支付订单号" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-input-inline">
                                    <select id="status" lay-search="">
                                        <option value="">分账状态</option>
                                        <option value="0">待分账</option>
                                        <option value="1">分账处理中</option>
                                        <option value="2">成功</option>
                                        <option value="3">失败</option>

                                    </select>
                                </div>
                                <a id="search" class="layui-btn"><i class="layui-icon layui-icon-search"></i>搜索</a>
                            </div>
                        </div>
                    </div>

                    <table class="layui-hide center" id="XxPay_Mgr_Division_Record_dataAll" lay-filter="XxPay_Mgr_Division_Record_dataAll"></table>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['table','util', 'form', 'table', 'admin'], function(){
        var table = layui.table
        ,$ = layui.$
        ,form = layui.form
        ,element = layui.element
        ,table = layui.table
        ,admin = layui.admin;

        element.render('breadcrumb', 'breadcrumb');//渲染导航信息

        var tplStatus = function(d){
            if(d.status == 0) {
                return "<span style='color: blue'>待分账</span>";
            }else if(d.status == 1) {
                return "<span style='color: orangered'>分账处理中</span>";
            }else if(d.status == 2) {
                return "<span style='color: green'>成功</span>";
            }else if(d.status == 3) {
                return "<span style='color: red'>失败</span>";
            }
        };


        table.render({
            elem: '#XxPay_Mgr_Division_Record_dataAll'
            ,url: layui.setter.baseUrl + '/pay_division_record/list'
            ,where: { access_token: layui.data(layui.setter.tableName).access_token}
            ,id: 'tableReload'
            ,cols: [[
                {title: '系统用户', templet:'<div>{{ ( d.infoType =="1" ? "代理商": d.infoType =="2" ? "商户":"平台" ) + ":" + d.infoId}}</div>' }
                ,{field:'payOrderId', minWidth:'220', title: '支付订单号'}
                ,{title: '分账金额', templet: '<div>{{ d.divisionAmount/100 }}</div>'}
                ,{title: '状态', templet: tplStatus}
                ,{title: '创建时间', minWidth:170, templet: '<div>{{ layui.util.toDateString(d.createTime, "yyyy-MM-dd HH:mm:ss") }}</div>'}
            ]]
            ,page: true
            ,skin: 'line'
        });

        // 搜索
        $('#search').on('click', function() {
            var payOrderId = $('#payOrderId').val();
            var status = $("#status").val();
            //执行重载
            table.reload('tableReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where: {
                    payOrderId : payOrderId,
                    status : status
                }
            });
        });
        // 渲染表单
        form.render();
    });
    
</script>
